package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.service.DemoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class DemoController {
    
    private final DemoService demoService;
    
    public DemoController(DemoService demoService) {
        this.demoService = demoService;
    }
    
    @GetMapping("/hello")
    public Result<String> hello() {
        String message = demoService.getMessage();
        return Result.success(message);
    }

    @GetMapping("/error-test")
    public Result<String> errorTest() {
        return Result.error("这是一个错误测试");
    }
} 